﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ymatou.User.Dto.Auth;
using Ymatou.User.ServerResponse;

namespace Ymatou.UserAuth.Agent.Token
{
    /// <summary>
    /// user token agent api
    /// </summary>
    public interface IUserTokenAgent
    {
        /// <summary>
        /// RemoveToken
        /// </summary>
        /// <param name="token"></param>
        void RemoveToken(string token);
        /// <summary>
        /// 创建用户token
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        string CreateUserTokenByUserId(int userId);
        /// <summary>
        /// 创建Token，并写入cookie
        /// </summary>
        /// <param name="userId"></param>
        void CreateUserTokenAndWriteSSOCookie(int userId);
        /// <summary>
        /// 根据token请求 auth server 认证
        /// </summary>
        /// <param name="token"></param>
        /// <returns></returns>
        ResponseData<TokenResponseDto> RequestTokenAuth(string token);
        /// <summary>
        /// 验证用户cookie （SSO） 。
        /// </summary>
        /// <param name="redirectLoginPage">是否允许重定向到登陆页</param>
        /// <param name="redirectOpenAuht">是否允许定向到OpenAuth站点</param>
        void VerifyUserSSOCookieToken(bool redirectLoginPage, bool redirectOpenAuht = true);
        /// <summary>
        ///  验证用户cookie （SSO）。 
        /// </summary>
        /// <param name="redirectLoginPage">是否允许重定向到登陆页</param>    
        /// <param name="failAction">验证失败执行操作</param>
        /// <param name="successAction">验证成功执行操作</param>
        /// <param name="redirectOpenAuht">是否允许定向到OpenAuth站点</param>
        void VerifyUserSSOCookieToken(bool redirectLoginPage, Action failAction, Action<int> successAction, bool redirectOpenAuht = true);
        /// <summary>
        /// 验证用户token
        /// </summary>        
        /// <param name="originalVal">原始窜</param>
        /// <param name="sign">加密窜</param>
        /// <returns></returns>
        ResponseData<SignAuthResponseDto2> CheckSign(string originalVal, string sign);
        /// <summary>
        /// 验证用户token
        /// </summary>
        /// <param name="token">token</param>
        /// <param name="userId">userId</param>
        /// <returns></returns>
        ResponseData<SignAuthResponseDto2> CheckSign(string token, int userId);
    }
}
